﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Everynet.Models;



namespace Everynet.Controllers
{
    public class servicesController : Controller
    {
        private EverynetEntities db = new EverynetEntities();
        public ActionResult Index()
        {
            return View();
        }
        public ActionResult Host()
        {
            return View(); 
        }
        public ActionResult Backup()
        {
            return View();
        }
        public ActionResult NakedDSL(Int32? id)
        {
            //Return Dynamic plans NationalADSL2 Broadbands by Fixed ID.
            var model = new PlanDetailModel();
            string viewCall = String.Empty;
            if (id == null)
            {
                Int32 selectedEnum = (int)Everynet.Models.signUpModel.enumPlanNames.NakedDSL;
                model.PlanDetailList = (from pro in db.PlanNamesDetails where pro.PlanNamesID == selectedEnum && pro.VisiblePublic == true orderby pro.Price ascending select new PlanDetailModel() { PlanNamesDetailID = pro.PlanNamesDetailID, PlanDetailName = pro.PlanDetailName, PlanDetailQuota = pro.PlanDetailQuota, Price = pro.Price, PlanNamesID = pro.PlanNamesID }).ToList();
                viewCall = "NakedDSL";
            }
            else
            {
                //Return Dynamic plans TransACT Broadbands by Fixed ID.
                model = (from e in db.PlanNamesDetails
                         where e.PlanNamesDetailID == id && e.VisiblePublic == true
                         orderby e.Price ascending
                         select new PlanDetailModel() { PlanNamesDetailID = e.PlanNamesDetailID, PlanDetailName = e.PlanDetailName, PlanDetailQuota = e.PlanDetailQuota, Price = e.Price, PlanNamesID = e.PlanNamesID }).SingleOrDefault();
                model.PlanQuotaList = (from pro in db.PlanQuotas where pro.VisiblePublic == true && pro.PlanNamesID == (int)@signUpModel.enumPlanNames.NakedDSL && pro.PlanNamesDetailID == id orderby pro.PlanQuotaValue ascending select new PlanQuotaModel() { PlanQuotaID = pro.PlanQuotaID, PlanQuotaValue = pro.PlanQuotaValue, PlanQuotaInterval = pro.PlanQuotaInterval, SetupCost = pro.SetupCost, EarlyExitFee = pro.EarlyExitFee, Comment = pro.Comment }).ToList();
                viewCall = "NakedDSLDetail";
            }
            return View(viewCall, model);
        }
        public ActionResult NationalADSL2(Int32? id)
        {
            //Return Dynamic plans NationalADSL2 Broadbands by Fixed ID.
            var model = new PlanDetailModel();
            string viewCall = String.Empty;
            if (id == null)
            {
                Int32 selectedEnum = (int)Everynet.Models.signUpModel.enumPlanNames.NationalADSL2;
                model.PlanDetailList = (from pro in db.PlanNamesDetails where pro.PlanNamesID == selectedEnum && pro.VisiblePublic==true orderby pro.Price ascending select new PlanDetailModel() { PlanNamesDetailID = pro.PlanNamesDetailID, PlanDetailName = pro.PlanDetailName, PlanDetailQuota = pro.PlanDetailQuota, Price = pro.Price, PlanNamesID = pro.PlanNamesID }).ToList();
                viewCall = "NationalADSL2";
            }
            else
            {
                //Return Dynamic plans TransACT Broadbands by Fixed ID.
                model = (from e in db.PlanNamesDetails
                         where e.PlanNamesDetailID == id && e.VisiblePublic==true orderby e.Price ascending
                         select new PlanDetailModel() { PlanNamesDetailID = e.PlanNamesDetailID, PlanDetailName = e.PlanDetailName, PlanDetailQuota = e.PlanDetailQuota, Price = e.Price, PlanNamesID = e.PlanNamesID }).SingleOrDefault();
                model.PlanQuotaList = (from pro in db.PlanQuotas where pro.VisiblePublic == true && pro.PlanNamesID == (int)@signUpModel.enumPlanNames.NationalADSL2 && pro.PlanNamesDetailID == id orderby pro.PlanQuotaValue ascending select new PlanQuotaModel() { PlanQuotaID = pro.PlanQuotaID, PlanQuotaValue = pro.PlanQuotaValue, PlanQuotaInterval = pro.PlanQuotaInterval, SetupCost = pro.SetupCost, EarlyExitFee = pro.EarlyExitFee, Comment = pro.Comment }).ToList();
                viewCall = "NationalADSL2Detail";
            }
            return View(viewCall, model);
        }
        public ActionResult TransACTResidential(Int32? id)
        {
            var model = new PlanDetailModel();
            string viewCall = String.Empty;
            if (id == null)
            {
                Int32 selectedEnum= (int)Everynet.Models.signUpModel.enumPlanNames.TransACTResidential;
                //Return Dynamic plans TransACT Broadbands by Fixed ID.
                model.PlanDetailList = (from pro in db.PlanNamesDetails where pro.PlanNamesID == selectedEnum && pro.VisiblePublic == true orderby pro.Price ascending select new PlanDetailModel() { PlanNamesDetailID = pro.PlanNamesDetailID, PlanDetailName = pro.PlanDetailName, PlanDetailQuota = pro.PlanDetailQuota, Price = pro.Price, PlanNamesID = pro.PlanNamesID }).ToList();
                viewCall = "TransACTResidential";
            }
            else
            {
                //Return Dynamic plans TransACT Broadbands by Fixed ID.
                model = (from e in db.PlanNamesDetails
                         where e.PlanNamesDetailID == id && e.VisiblePublic==true
                         orderby e.Price ascending
                         select new PlanDetailModel() { PlanNamesDetailID = e.PlanNamesDetailID, PlanDetailName = e.PlanDetailName, PlanDetailQuota = e.PlanDetailQuota, Price = e.Price, PlanNamesID = e.PlanNamesID }).SingleOrDefault();
                model.PlanQuotaList = (from pro in db.PlanQuotas where pro.VisiblePublic == true && pro.PlanNamesID == (int)@signUpModel.enumPlanNames.TransACTResidential && pro.PlanNamesDetailID == id orderby pro.PlanQuotaValue ascending select new PlanQuotaModel() { PlanQuotaID = pro.PlanQuotaID, PlanQuotaValue = pro.PlanQuotaValue, PlanQuotaInterval = pro.PlanQuotaInterval, SetupCost = pro.SetupCost, EarlyExitFee=pro.EarlyExitFee, Comment=pro.Comment}).ToList();
                viewCall = "TransACTResidentialDetail";
            }
            return View(viewCall, model);
        }
        public ActionResult TransACTBusiness(Int32? id)
        {
            var model = new PlanDetailModel();
            string viewCall = String.Empty;
            if (id == null)
            {
                Int32 selectedEnum = (int)Everynet.Models.signUpModel.enumPlanNames.TransACTBusiness;
                //Return Dynamic plans TransACTBusiness by Fixed ID.
                model.PlanDetailList = (from pro in db.PlanNamesDetails where pro.PlanNamesID == selectedEnum && pro.VisiblePublic == true orderby pro.Price ascending select new PlanDetailModel() { PlanNamesDetailID = pro.PlanNamesDetailID, PlanDetailName = pro.PlanDetailName, PlanDetailQuota = pro.PlanDetailQuota, Price = pro.Price, PlanNamesID = pro.PlanNamesID }).ToList();
                viewCall = "TransACTBusiness";
            }
            else
            {
                //Return Dynamic plans TransACTBusiness by Fixed ID.
                model = (from e in db.PlanNamesDetails
                         where e.PlanNamesDetailID == id && e.VisiblePublic == true
                         orderby e.Price ascending
                         select new PlanDetailModel() { PlanNamesDetailID = e.PlanNamesDetailID, PlanDetailName = e.PlanDetailName, PlanDetailQuota = e.PlanDetailQuota, Price = e.Price, PlanNamesID = e.PlanNamesID }).SingleOrDefault();
                model.PlanQuotaList = (from pro in db.PlanQuotas where pro.VisiblePublic == true && pro.PlanNamesID == (int)@signUpModel.enumPlanNames.TransACTBusiness && pro.PlanNamesDetailID == id orderby pro.PlanQuotaValue ascending select new PlanQuotaModel() { PlanQuotaID = pro.PlanQuotaID, PlanQuotaValue = pro.PlanQuotaValue, PlanQuotaInterval = pro.PlanQuotaInterval, SetupCost = pro.SetupCost, EarlyExitFee = pro.EarlyExitFee, Comment = pro.Comment }).ToList();
                viewCall = "TransACTBusinessDetail";
            }
            return View(viewCall, model);
        }
        public ActionResult RegionalADSL(Int32? id)
        {
            //Return Dynamic plans NationalADSL2 Broadbands by Fixed ID.
            var model = new PlanDetailModel();
            string viewCall = String.Empty;
            if (id == null)
            {
                Int32 selectedEnum = (int)Everynet.Models.signUpModel.enumPlanNames.RegionalADSL2;
                model.PlanDetailList = (from pro in db.PlanNamesDetails where pro.PlanNamesID == selectedEnum && pro.VisiblePublic == true orderby pro.Price ascending select new PlanDetailModel() { PlanNamesDetailID = pro.PlanNamesDetailID, PlanDetailName = pro.PlanDetailName, PlanDetailQuota = pro.PlanDetailQuota, Price = pro.Price, PlanNamesID = pro.PlanNamesID }).ToList();
                viewCall = "RegionalADSL";
            }
            else
            {
                //Return Dynamic plans TransACT Broadbands by Fixed ID.
                model = (from e in db.PlanNamesDetails
                         where e.PlanNamesDetailID == id && e.VisiblePublic==true
                         orderby e.Price ascending
                         select new PlanDetailModel() { PlanNamesDetailID = e.PlanNamesDetailID, PlanDetailName = e.PlanDetailName, PlanDetailQuota = e.PlanDetailQuota, Price = e.Price, PlanNamesID = e.PlanNamesID }).SingleOrDefault();
                model.PlanQuotaList = (from pro in db.PlanQuotas where pro.VisiblePublic == true && pro.PlanNamesID == (int)@signUpModel.enumPlanNames.RegionalADSL2 && pro.PlanNamesDetailID == id orderby pro.PlanQuotaValue ascending select new PlanQuotaModel() { PlanQuotaID = pro.PlanQuotaID, PlanQuotaValue = pro.PlanQuotaValue, PlanQuotaInterval = pro.PlanQuotaInterval, SetupCost = pro.SetupCost, EarlyExitFee = pro.EarlyExitFee, Comment = pro.Comment }).ToList();
                viewCall = "RegionalADSLDetail";
            }
            return View(viewCall, model);
        }

        public ActionResult NBN(Int32? id)
        {
            //Return Dynamic plans NationalADSL2 Broadbands by Fixed ID.
            var model = new PlanDetailModel();
            string viewCall = String.Empty;
            if (id == null)
            {
                Int32 selectedEnum = (int)Everynet.Models.signUpModel.enumPlanNames.NBNFibre12MDownload;
                Int32 selectedEnum25 = (int)Everynet.Models.signUpModel.enumPlanNames.NBNFibre25MDownload;
                Int32 selectedEnum50 = (int)Everynet.Models.signUpModel.enumPlanNames.NBNFibre50MDownload;
                Int32 selectedEnum100 = (int)Everynet.Models.signUpModel.enumPlanNames.NBNFibre100MDownload;

                model.PlanList = (from pro in db.PlanNames where (pro.ID == selectedEnum || pro.ID == selectedEnum25 || pro.ID == selectedEnum50 || pro.ID == selectedEnum100) && pro.VisiblePublic == true orderby pro.ID ascending select new PlanModel() { ID = pro.ID, Name = pro.Name}).ToList();
                model.PlanDetailList = (from pro in db.PlanNamesDetails where (pro.PlanNamesID == selectedEnum || pro.PlanNamesID == selectedEnum25 || pro.PlanNamesID == selectedEnum50 || pro.PlanNamesID == selectedEnum100) && pro.VisiblePublic == true orderby pro.Price ascending select new PlanDetailModel() { PlanNamesDetailID = pro.PlanNamesDetailID, PlanDetailName = pro.PlanDetailName, PlanDetailQuota = pro.PlanDetailQuota, Price = pro.Price, PlanNamesID = pro.PlanNamesID }).ToList();    
                viewCall = "NBN";
            }
            else
            {
                //Return Dynamic plans TransACT Broadbands by Fixed ID.
                //Int32 selectedEnum = (int)Everynet.Models.signUpModel.enumPlanNames.NBNFibre12MDownload;
               
                model = (from e in db.PlanNamesDetails
                         where e.PlanNamesDetailID == id && e.VisiblePublic == true
                         orderby e.Price ascending
                         select new PlanDetailModel() { PlanNamesDetailID = e.PlanNamesDetailID, PlanDetailName = e.PlanDetailName, PlanDetailQuota = e.PlanDetailQuota, Price = e.Price, PlanNamesID = e.PlanNamesID }).SingleOrDefault();
                model.PlanQuotaList = (from pro in db.PlanQuotas where pro.VisiblePublic == true && pro.PlanNamesDetailID == id orderby pro.PlanQuotaValue ascending select new PlanQuotaModel() { PlanQuotaID = pro.PlanQuotaID, PlanQuotaValue = pro.PlanQuotaValue, PlanQuotaInterval = pro.PlanQuotaInterval, SetupCost = pro.SetupCost, EarlyExitFee = pro.EarlyExitFee, Comment = pro.Comment }).ToList().Distinct();
                viewCall = "NBNDetail";
                //&& (pro.PlanNamesID == selectedEnum)
            }
            return View(viewCall, model);
        }
    }
}